﻿using Basic.FlowGatewayModule.Interface;
using Basic.FlowGatewayModule.Model;
using Basic.FlowRemoteModel;
using Basic.FlowRemoteModel.Application.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FlowGatewayModule.Api
{
    [ApiRouteName("/flow/audit/{name}")]
    internal class FlowAuditApi : ApiController
    {
        private readonly IFlowAuditService _Service;

        public FlowAuditApi ( IFlowAuditService service )
        {
            this._Service = service;
        }

        public FlowNodeState[] GetNodeState ( [NumValidate("flow.audit.log.id.error", 1)] long logId, [NumValidate("flow.id.error", 1)] long flowId )
        {
            return this._Service.GetNodeState(logId, flowId);
        }
        public FlowFile[] GetFiles ( [NumValidate("flow.audit.log.id.error", 1)] long logId )
        {
            return this._Service.GetFiles(logId);
        }
        public CreateAuditResult BeginAudit ( BeginFlowArg arg )
        {
            return this._Service.BeginAudit(arg, base.UserState);
        }
        public CopyNodeLog GetCopyLog ( [NumValidate("flow.copy.log.id.error", 1)] long id )
        {
            return this._Service.GetCopyLog(id, base.UserState.ToEmpId());
        }
        public FlowAuditLog GetAuditLog ( [NumValidate("flow.audit.log.id.error", 1)] long logId )
        {
            return this._Service.GetAuditLog(logId);
        }
        public AuditNodeLog GetCurentNode ( [NumValidate("flow.audit.item.id.error", 1)] long id )
        {
            return this._Service.GetCurentNode(id, base.UserState.ToEmpId());
        }

        public NextStepResult GetNextStep ( [NumValidate("flow.audit.item.id.error", 1)] long id )
        {
            return this._Service.GetNextStep(id);
        }

        public FlowAuditItemStatus Submit ( LongParam<AuditRes> arg )
        {
            arg.Value.AuditEmpId = base.UserState.ToEmpId();
            return this._Service.Submit(arg.Id, arg.Value);
        }
    }
}
